      1  /**

      2     This program runs threads that deposit and withdraw

      3     money from the same bank account.

      4  */

      5  public class BankAccountThreadRunner

      6  {

      7     public static void main(String[] args)

      8     {

      9        BankAccount account = new BankAccount();

     10        final double AMOUNT = 100;

     11        final int REPETITIONS = 100;

     12        final int THREADS = 100;

     13

     14        for (int i = 1; i <= THREADS; i++)

     15        {

     16           DepositRunnable d = new DepositRunnable(

     17              account, AMOUNT, REPETITIONS);

     18           WithdrawRunnable w = new WithdrawRunnable(

     19              account, AMOUNT, REPETITIONS);

     20

     21           Thread dt = new Thread(d);

     22           Thread wt = new Thread(w);

     23

     24           dt.start();

     25           wt.start();

     26        }

     27     }

     28  }

     29